﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using Microsoft.ApplicationBlocks.Data;
using System.Security.Cryptography;
using Entity;

namespace DAO
{
    public class InHoaDonDAO
    {
        public static DataTable HoaDonXH(String maphieu)
        {
            SqlConnection connect = null;
            DataTable rs = null;

            try
            {
                try
                {
                    connect = Connection.GetConnection();
                }
                catch
                {
                    throw new Exception("The connection with the database can´t be established");
                }
                SqlParameter[] par = new SqlParameter[1];
                par[0] = new SqlParameter("@maphieu", maphieu);
                rs = SqlHelper.ExecuteDataset(connect, CommandType.StoredProcedure, "usp_HoaDonXH", par).Tables[0];
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                if (rs != null)
                    ((IDisposable)rs).Dispose();

                if (connect != null)
                    connect.Dispose();
            }

            return rs;
        }
    }
}
